home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-12-17 | 29.6 KB | 713 lines | [TEXT/MPS ] |
- #
- # ****************************************************************************
- #
- # File Name: Font.Lib
- #
- # Contains: xxx put contents here xxx
- #
- # Written by: Kevin Avoy, Ken Landreth, Michael Leong, Gil Spencer et al
- #
- # Copyright: © 1993 by Apple Computer, Inc., all rights reserved.
- #
- # ****************************************************************************
- # C h a n g e H i s t o r y (most recent first):
- # ****************************************************************************
- #
- # Vers Date Author Description
- # ---- -------- ------ ---------------------------------------------
- # 1.0.13+> 11/19/93 NAGA modify TCS format
- # <1.0.13> 9/22/93 KTA Removed gHandleTextEntry as no one was using it.
- # <1.0.12> 9/13/93 KTA Updated TestLevel specification.
- # <1.0.11> 8/30/93 KTA Updated task headers and parameters.
- # <1.0.10> 8/25/93 KTA Added support for parity checking the TCS stack.
- # <1.0.9> 7/30/93 KTA Added checks in SetStyle(), SetSize(), SetFont() to see if
- # menuItem is enabled. If not TCSReturn := -1.
- # <1.0.8> 7/23/93 KTA SetStyle() - gCurrStyleMenu - Help insure that it is initilized
- # correctly.
- # <1.0.7> 7/14/93 KTA International Support: See InitFonts(),
- # ReportSelectedMenuItems(), SetFont(), SetStyle(), SetSize(). Now
- # depends on Output.Lib.
- # <1.0.5> 6/8/93 NAGA unmark tasks that are not to be published
- # <1.0.3> 5/21/93 NAGA Adding header and porting old files to follow new standards
- #
- # ****************************************************************************
- #
-
- ########################################################################
- # External libraries
- #=======================================================================
- Libraries "TCS.Lib","UserInterface.Lib", "OutPut.Lib";
-
-
- #########################################################################
- # Font.Lib
- #========================================================================
- # Description: This module contains VU code for exercising fonts, styles, and
- # sizes. There are three modes of font testing currently defined.
- # These can be executed by calling DoText with certain globals set
- # appropriately. The following section details the proper global
- # settings to execute the various test methods.
- # All of the methods are based on the execution of a FontRecord which
- # consists of three elements {"FontName", "SizeName", {StyleList}};
- # For example: ourFontRecord := {'Geneva','12',{'Bold','Italic'}};
- #
- #
- # ---- globals ----
- # In order to execute any of the font testing methods there are a
- # series of globals that must be defined in the Task-InitFonts();
- #
- # All font characteristics are generated from the predefined global
- # font lists: gFontList, gFontSizeList, gFontStyleList.
- # Define these lists with appropriate Fonts, Sizes and Styles.
- # These are the first block of globals in InitFontglobals();
- #
- # DO NOT define the second block of globals (gCurrFontMenu, gCurrSizeMenu,
- # gCurrStyleMenu). These globals will be automatically defined. They
- # store the titles to the menus which contain the font characteristic
- # menu items.
- #
- # The global gPlainStyle should be defined as the menu item which clears
- # all font styles.
- #
- # The global gNextLineMethod should be defined as the appropriate method
- # which a particular application requires to be prepared to enter the
- # next line of text.
- #
- # The global gNextLineClearsFontSettings should be set to a 1 if the
- # method of moving to the next line of text clears all the font settings.
- # It should be set to 0 if moving to the next line retains the font
- # settings - ( important if the test method is kWaterFall - see below)
- #
- #
- # ---- TEST METHODS ----
- # • Generate Random FontRecords -
- # 1) Set gFontLevel to equal kRandomText. (i.e. global gFontLevel := kRandomText;)
- # 2) Set NumTimes input parameter to equal the number of random text records.
- # DoText(3,5); # For 5 random text records
- # 3) Call DoText();
- #
- # - The FontRecord generated will include a random Font, a random size,
- # and a random number of random styles.
- #
- # • QuickLook method -
- # 1) Set gFontLevel to equal kQLFontTest. (i.e. global gFontLevel := kQLFontTest;)
- # 2) Call DoText();
- #
- # - This will generated 1 FontRecord for each font with a random size and
- # a random combination of styles.
- #
- # • WaterFall method -
- # 1) Set gFontLevel to equal kWaterFall. (i.e. global gFontLevel := kWaterFall;)
- # 2) Be sure the global gNextLineClearsFontSettings is set correctly (See above)
- # 3) Call DoText();
- #
- # - This will generated 1 FontRecord for each font with every size and combination
- # of styles.
- # For example the first record may be {"Helvetica", '12', {'Bold'}}; and the
- # second record might be {"Helvetica", '12', {'Bold', 'italic'}}
- #
- # Copyright Apple Computer, Inc. 1985-1991
- # All rights reserved
- #
- #========================================================================
- # History:
- #
- #########################################################################
-
- ##### Accessors ####
- task ReplaceFont(pCurrentFont,pCurrentFontRecord) begin return(Replace(pCurrentFont,1,pCurrentFontRecord)); end;
- task ReplaceFontSize(pCurrentSize,pCurrentFontRecord) begin return(Replace(pCurrentSize,2,pCurrentFontRecord)); end;
- task ReplaceFontStyle(pStyleList,pCurrentFontRecord) begin return(Replace(pStyleList,3,pCurrentFontRecord)); end;
-
-
- #########################################################################
- # InitFonts()
- #========================================================================
- # Author: KTA
- # Description: Initializes the font globals.
- # Parameters: None
- # Returns: Nada
- # Examples: InitFonts();
- # Assumptions:
- #========================================================================
- # History:
- # KTA 7/8/93 Move gFontList, gFontStyleList, gFontSizeList to Globals.Lib (intl)
- #########################################################################
- TASK InitFonts()
- begin
- #===== Task references =======
- global gSetFont := Task SetFont; # Requires VU 2.0
- global gSetSize := Task SetSize; # Requires VU 2.0
- global gSetStyle := Task SetStyle; # Requires VU 2.0
- global gNextLine := Task NextLine; # Requires VU 2.0
-
- global gFontObject := 0; # Object Number in a given suite
-
- #======= font characteristic lists >> Moved to Globals.Lib =======
-
- #####################################################################
- #### Do not change the values below!!!
- #### The following Globals are default values and if an application needs
- #### to override them it should be done from within the script.
- #####################################################################
- ### Name of the Plain (style) menu item ####
- global gPlainStyle := "Plain"; # Plain-Style menu item
-
- ### How to get to the next line
- global gNextLineMethod := 1;
- ### 1 - ReturnKey, 2 - EnterKey, 3 - DownArrow Key, 4 - TabKey, {} - Move/Click, {'Untitled'} - Move relative to the window titled 'Untitled' /Click
-
- ### Does moving to the next line clear all font info
- global gNextLineClearsFontSettings := 1;
- end;
- #########################################################################
- # SetFont(pMyFont, pObjectNumber)
- #========================================================================
- # Author: KTA
- # Description: Selects <pMyFont> menuitem to set the current font.
- # Parameters: pMyFont - Name of the font.
- # pObjectNumber - Integer used to track all elements that make up
- # an Font record - TCS related.
- # Returns: returns what SelectMenuItem returns
- # 0 - failure
- # String - success
- # Examples: SetFont('Geneva');
- # Assumptions: That InitFonts() has been called thus global gCurrFontMenu
- # is set to the name of the menus which contain <pMyFont>
- #========================================================================
- # History:
- # KTA 7/8/93 gCurrFontMenu update for intl
- # KTA 7/30/93 TCSReturn -1 if menuItem is not enabled
- # KTA 8/24/93 TCS stack parity check
- #########################################################################
- TASK SetFont(pMyFont := '', pObjectNumber := 'NA')
- begin
- failStr := "";
- returnVal := 0;
- if not(global gCurrFontMenu) # Menu(s) which contain the menu item
- begin
- gCurrFontMenu := FindMenu(global gFontList[1]);
- if not(gCurrFontMenu) # Menu(s) which contain the menu item
- gCurrFontMenu := FindMenu("Chicago");
- end;
-
- if (gCurrFontMenu)
- begin
- TCSStart({ 1, global kTCSetFont},"SetFont"); # Start TCS
- returnVal := SelectMenuItem(pMyFont,gCurrFontMenu[1],gCurrFontMenu[2]); # Select the font from the Font menu
- if (returnVal)
- myReturn := 1;
- else # No returnVal - SelectMenuItem failed
- begin
- if (gCurrFontMenu[2])
- theMenuItem := match[menuItem t:pMyFont m:[menuItem t:gCurrFontMenu[1] m:[menu t:gCurrFontMenu[2]]]]!;
- else
- theMenuItem := match[menuItem t:pMyFont m:[menu t:gCurrFontMenu[1]]]!;
- if(theMenuItem)
- begin
- if (theMenuItem.e)
- begin
- myReturn := -1; # disabled menuItem - expected that can't be selected
- failStr := "MenuItem is disabled so it couldn't be selected";
- end;
- end;
- else
- begin
- myReturn := returnVal;
- failStr := "Couldn't select menuItem, it is not present.";
- end;
- end;
-
- TCSEnd( {1, global kTCSetFont}, myReturn,failStr,pObjectNumber,pMyFont);
- end;
- else
- LogStr("Sorry, can't locate the font menu. Is the gFontList set up correctly?");
- return(returnVal);
- end; # SetFont()
-
- #########################################################################
- # SetStyle(pMyStyle, pObjectNumber)
- #========================================================================
- # Author: KTA
- # Description: Sets the currently selected font style to <pMyStyle>
- # Parameters: pMyStyle - Name of the Style.
- # pObjectNumber - Integer used to track all elements that make up
- # an Font record - TCS related.
- # Returns: returns what SelectMenuItem returns
- # 0 - failure
- # String - success
- # Examples: SetStyle('Bold');
- # Assumptions: That InitFonts() has been called thus global gCurrStyleMenu
- # is set to the name of the menus which contain <pMyStyle>
- #========================================================================
- # History:
- # KTA 7/8/93 gCurrStyleMenu update for intl
- # KTA 7/23/93 gCurrStyleMenu - Help insure that it is initilized correctly
- # KTA 7/30/93 TCSReturn -1 if menuItem is not enabled
- # KTA 8/24/93 TCS stack parity check
- #########################################################################
- TASK SetStyle(pMyStyle := '', pObjectNumber := 'NA')
- begin
- failStr := "";
- returnVal := 0;
- if not(global gCurrStyleMenu) # Menu(s) which contain the menu item
- begin
- if (global gFontStyleList[1])
- gCurrStyleMenu := FindMenu(global gFontStyleList[1]);
- if not(gCurrStyleMenu) # Help insure that it is initilized correctly
- gCurrStyleMenu := FindMenu('Bold');
- end;
- if (gCurrStyleMenu)
- begin
- TCSStart({ 3, global kTCSetFont},"SetStyle"); # Start TCS
- returnVal := SelectMenuItem(pMyStyle,gCurrStyleMenu[1],gCurrStyleMenu[2]); # Select the font from the Font menu
- if (returnVal)
- myReturn := 1;
- else # No returnVal - SelectMenuItem failed
- begin
- if (gCurrStyleMenu[2])
- theMenuItem := match[menuItem t:pMyStyle m:[menuItem t:gCurrStyleMenu[1] m:[menu t:gCurrStyleMenu[2]]]]!;
- else
- theMenuItem := match[menuItem t:pMyStyle m:[menu t:gCurrStyleMenu[1]]]!;
- if(theMenuItem)
- begin
- if (theMenuItem.e)
- begin
- myReturn := -1; # disabled menuItem - expected that can't be selected
- failStr := "MenuItem is disabled so it couldn't be selected";
- end;
- end;
- else
- begin
- myReturn := returnVal;
- failStr := "Couldn't select menuItem, it is not present.";
- end;
- end;
-
- TCSEnd({ 3, global kTCSetFont }, myReturn,failStr,pObjectNumber,pMyStyle);
- end;
- else
- LogStr("Sorry, can't locate the style menu. Is the gFontStyleList set up correctly?");
- return(returnVal);
- end; # SetStyle()
-
- #########################################################################
- # SetSize(pMySize, pObjectNumber)
- #========================================================================
- # Author: KTA
- # Description: Sets the currently selected font size to <pMySize>
- # Parameters: pMySize - Name of the size.
- # pObjectNumber - Integer used to track all elements that make up
- # an Font record - TCS related.
- # Returns: returns what SelectMenuItem returns
- # 0 - failure
- # String - success
- # Examples: SetSize('10');
- # Assumptions: That InitFonts() has been called thus global gCurrSizeMenu
- # is set to the name of the menus which contain <pMySize>
- #========================================================================
- # History:
- # KTA 7/8/93 gCurrSizeMenu update for intl
- # KTA 7/30/93 TCSReturn -1 if menuItem is not enabled
- # KTA 8/24/93 TCS stack parity check
- #########################################################################
- TASK SetSize(pMySize := '', pObjectNumber := 'NA')
- begin
- failStr := '';
- returnVal :=0;
- if not(global gCurrSizeMenu) # Menu(s) which contain the menu item
- gCurrSizeMenu := FindMenu(global gFontSizeList[1]);
- if (gCurrSizeMenu)
- begin
- TCSStart({ 2, global kTCSetFont },"SetSize"); # Start TCS
- returnVal := SelectMenuItem(pMySize,gCurrSizeMenu[1],gCurrSizeMenu[2]); # Select the font from the Font menu
- if (returnVal)
- myReturn := 1;
- else # No returnVal - SelectMenuItem failed
- begin
- if (gCurrSizeMenu[2])
- theMenuItem := match[menuItem t:pMySize m:[menuItem t:gCurrSizeMenu[1] m:[menu t:gCurrSizeMenu[2]]]]!;
- else
- theMenuItem := match[menuItem t:pMySize m:[menu t:gCurrSizeMenu[1]]]!;
- if(theMenuItem)
- begin
- if (theMenuItem.e)
- begin
- myReturn := -1; # disabled menuItem - expected that can't be selected
- failStr := "MenuItem is disabled so it couldn't be selected";
- end;
- end;
- else
- begin
- myReturn := returnVal;
- failStr := "Couldn't select menuItem, it is not present.";
- end;
- end;
-
- TCSEnd({ 2, global kTCSetFont }, myReturn,failStr,pObjectNumber,pMySize);
- end;
- else
- LogStr("Sorry, can't locate the size menu. Is the gFontSizeList set up correctly?");
- return(returnVal);
- end; # SetSize()
-
- #########################################################################
- # NextLine()
- #========================================================================
- # Author: KTA
- # Description: Prepares application to accept the next line of text
- # Parameters: None
- # gNextLineMethod =
- # 1 - ReturnKey
- # 2 - Enter Key
- # 3 - Down Arrow Key
- # 4 - Tab Key
- # {<Optional Specifier>} - if no specifier will select the
- # first document window with close and grow box.
- # Returns: Nada
- # Examples: NextLine();
- # Assumptions: global gNextLineMethod is set to the correct method required for
- # preparing the application to accept the next line of text.
- #========================================================================
- # History:
- #
- #########################################################################
- TASK NextLine() begin
- global gNextLineMethod;
- ### For more than 1 line of text a new line must be selected
- if (TypeOf(gNextLineMethod) = 'integer')
- begin
- ### Cases of Keystrokes to move to next line
- if (gNextLineMethod = 1) # 1 - ReturnKey
- SpecialKey(returnKey,"Return Key");
- else if (gNextLineMethod = 2) # 2 - EnterKey
- SpecialKey(enterKey,"Enter Key");
- else if (gNextLineMethod = 3) # 3 - DownArrow Key
- SpecialKey(downarrowKey,"Down Arrow Key");
- else if (gNextLineMethod = 4) # 4 - TabKey
- SpecialKey(tabKey,"Tab Key");
- end;
- else
- begin
- #you want random move and click
- if(gNextLineMethod = {}) # {} - Move/Click
- whichWindow := 0;
- else
- whichWindow := gNextLineMethod[1]; # {} - Move relative to the window <gNextLineMethod[1]> then Click
-
- MoveRelativeToWindow('random','random',whichWindow,2,{60,60,30,30}); #move pointer to a random
- end;
- end; # NextLine()
-
-
- #########################################################################
- # RandomFontRecords(pCurrentFontRecord)
- #========================================================================
- # Author: KTA
- # Description: Creates random font records based on the globals: gFontList,
- # gFontSizeList, gFontStyleList.
- # Parameters: pCurrentFontRecord - The script writer can define a partial record
- # and a complete record will be returned.
- # Returns: pCurrentFontRecord := {FontName, SizeName,{StyleName1, StyleName2}};
- # Examples: RandomFontRecords(); may return - {'Geneva','12'{'Bold','Italic'}}
- # Assumptions:
- #========================================================================
- # History:
- #
- #########################################################################
- TASK RandomFontRecords(pCurrentFontRecord := {"","",""})
- begin
- global gFontList, gFontSizeList, gFontStyleList;
- if (pCurrentFontRecord[1] = "")
- begin
- ### Font assignment ####
- whichFont := Random(1,Card(gFontList)); # Random font position
- currentFont := gFontList[whichFont]; # Assign font from random position in list
- # Replace old font with new
- pCurrentFontRecord := ReplaceFont(currentFont,pCurrentFontRecord);
- end;
- if (pCurrentFontRecord[2] = "")
- begin
- ### Size assignment ####
- whichSize := Random(1,Card(gFontSizeList)); # Random size position
- currentSize := gFontSizeList[whichSize]; # Assign size from random position in list
- # Replace old size with new
- pCurrentFontRecord := ReplaceFontSize(currentSize,pCurrentFontRecord);
- end;
- if (pCurrentFontRecord[3] = "")
- begin
- if (gFontStyleList) # Insure that gFontStyleList is defined
- begin
- ### Style assignment ####
- availStyleList := gFontStyleList; # Assign global gFontStyleList to a temp value
- styleList := {}; # Init the styleList
- for numStyle := 1 to (Random(1, Card(availStyleList))) # Add random number of styles (from 1 to random numbr of styles avail)
- begin
- RandNum := Random(1,Card availStyleList); # Select a random style from list of available styles
- styleList := Insert(availStyleList[RandNum],(Card(StyleList)+1),StyleList); #Insert the random style into the end of the current Style list
- availStyleList := Remove(RandNum,availStyleList); # Remove the Style from available Styles
- end;
- # Replace old StyleList with new
- pCurrentFontRecord := ReplaceFontStyle(StyleList,pCurrentFontRecord);
- end;
- end;
- return( pCurrentFontRecord );
- end; # RandomFontRecords()
-
-
- #########################################################################
- # WaterFallFontTest()
- #========================================================================
- # Author: KTA
- # Description: Creates and executes font records based on the globals: gFontList,
- # gFontSizeList, gFontStyleList. For each Font, each defined size will
- # be selected, with each of the defined styles.
- # Parameters: None
- # Returns: nada
- # Examples: WaterFallFontTest();
- # Assumptions: global gPlainStyle is defined as the Plain style menu item
- #========================================================================
- # History:
- #
- #########################################################################
- TASK WaterFallFontTest()
- begin
- global gFontList, gFontSizeList, gFontStyleList,gPlainStyle,gCurrFontMenu,gCurrStyleMenu,
- gCurrSizeMenu,gNextLineMethod,gNextLineClearsFontSettings, gFontObject;
- styleList := {}; # Init styleList
- currentFontRecord := {"","",""}; # Init currentFontRecord
- resetPlainFlag := 1; # Init resetPlainFlag
- if (gNextLineClearsFontSettings) # Does method of moving to the next line clear the font settings
- begin
- completeRecord := 1; # If it does we need a complete record
- resetPlainFlag := 0; # we also don't need to reset the styles to plain
- end;
- ### Font assignment ####
- for each currentFont in gFontList # Do this for all the fonts in global gFontList.
- begin
- gFontObject := gFontObject + 1; # Increment the object number for TCS info
- currentFontRecord := ReplaceFont(currentFont,currentFontRecord); # Place current font into current fontRecord
- continueFlag := 1;
- ### Size assignment ####
- for each currentSize in gFontSizeList # Do this for each size in global gFontSizeList
- begin
- if (continueFlag)
- begin
- currentFontRecord := ReplaceFontSize(currentSize,currentFontRecord); # Place current size into current fontRecord
- if(resetPlainFlag) and (gPlainStyle) # Do we want to reset the styles to plain between style selection
- Call (global gSetStyle, gPlainStyle,gFontObject);
- ### Style assignment ####
- styleList := {}; # ReInit styleList because we have a new size to deal with
- if (Card(gFontStyleList) > 0) # gFontStyleList needs to contain items
- begin
- for each currentStyle in gFontStyleList # Do this for all style defined in global gFontStyleList
- begin
- if (continueFlag)
- begin
- if not(completeRecord) # if we move to a random location and click all styles will be cleared so we want to have a complete list
- styleList := {}; # ReInit Stylelist because previous style will still be selected
- styleList := insert(currentStyle,(Card(StyleList)+1),styleList); # Build current styleList
-
- currentFontRecord := ReplaceFontStyle(StyleList, currentFontRecord); # Place current styleList into current fontRecord
- FontRecord := SetFontParams(currentFontRecord,0,gFontObject);
- If(FontRecord)
- begin
- ReportSelectedMenuItems({gCurrFontMenu,gCurrSizeMenu,gCurrStyleMenu},gFontObject); # Match and report back what is actually selected
- Println "• - ",FontRecord;
- end;
- else
- begin
- Println "NOTE: Couldn't complete FontRecord • - ", currentFontRecord;
- continueFlag := 0;
- end;
- if not(completeRecord) # If we don't need a complete record
- currentFontRecord := {"","",""}; # Reinitialize so were only passing a Style and not a complet record
- end;
- end;
- end;
- else # Handle an empty gFontStyleList
- begin
- FontRecord := SetFontParams(currentFontRecord,0,gFontObject);
- ReportSelectedMenuItems({gCurrFontMenu,gCurrSizeMenu},gFontObject); # Match and report back what is actually selected
- Println "• - ",FontRecord;
- end;
- end;
- end;
- end;
- end; # WaterFallFontTest()
- (*
- #########################################################################
- # QuickLookTextTest()
- #========================================================================
- # Author: KTA
- # Description: Creates and executes font records based on the globals: gFontList,
- # gFontSizeList, gFontStyleList. For each Font will select
- # random size and random number of styles.
- # Parameters: none
- # Returns: nada
- # Examples: QuickLookTextTest();
- # Assumptions: global gPlainStyle is defined as the Plain style menu item
- #========================================================================
- # History:
- #
- #########################################################################
- TASK QuickLookTextTest()
- begin
- global gFontList, gFontSizeList, gFontStyleList,gCurrStyleMenu,gNextLineMethod;
- styleList := {}; # Init styleList
- currentFontRecord := {"","",""}; # Init currentFontRecord
- ### Font assignment ####
- for each currentFont in gFontList # Do this for all the fonts in global gFontList.
- begin
- currentFontRecord := ReplaceFont(currentFont,currentFontRecord); # Place current font into current fontRecord
-
- ### Size assignment ####
- whichSize := Random(1,(Card gFontSizeList)); # Random Size
- currentSize := gFontSizeList[whichSize];
- currentFontRecord := ReplaceFontSize(currentSize,currentFontRecord); # Place current size into current fontRecord
-
- ### Style assignment ####
- availStyleList := gFontStyleList; # Assign global gFontStyleList to a temp value
- styleList := {}; # Init the styleList
- for numStyle := 1 to (Random(1, Card(availStyleList))) # Add random number of styles (from 1 to random numbr of styles avail)
- begin
- RandNum := Random(1,Card availStyleList); # Select a random style from list of available styles
- styleList := Insert(availStyleList[RandNum],(Card(StyleList)+1),StyleList); #Insert the random style into the end of the current Style list
- availStyleList := Remove(RandNum,availStyleList); # Remove the Style from available Styles
- end;
- # Replace old StyleList with new
- currentFontRecord := ReplaceFontStyle(StyleList,currentFontRecord);
- println "The current font record is: ",currentFontRecord;
- SetFontParams(currentFontRecord);
- end;
- end; # QuickLookTextTest()
- *)
- #########################################################################
- # SetFontParams(pFontRecord, pResetPlainFlag, pObjectNumber)
- #========================================================================
- # Author: KTA
- # Description: Executes font records bycalling the routines necessary for selecting
- # the font (pFontRecord[1]) if its defined, selecting the size
- # (pFontRecord[2]) if its defined, then selecting each style defined
- # in the styleRecord (pFontRecord[3]). ReportSelectedMenuItems is then
- # called to report all of the menu items in the appropriate menus
- # with a MarkChar.
- # Parameters: pFontRecord- {Font,Size,{Style1,Style2}}
- # pResetPlainFlag -
- # 1 - Select <gPlainStyle> before executing the StyleRecord
- # loop so styles will begin at a cleared state.
- # 0 - Won't select the plain menu item.
- # pObjectNumber - Integer used to track all elements that make up
- # an Font record - TCS related.
- # Returns: By default, returns what SetStyle returns
- # Examples: SetFontParams();
- # Assumptions: global gPlainStyle is defined as the Plain style menu item
- #========================================================================
- # History:
- #
- #########################################################################
- TASK SetFontParams(pFontRecord,pResetPlainFlag := 1, pObjectNumber)
- begin
- returnVal := 0;
- #Println "• - pFontRecord is: ",pFontRecord;
- global gPlainStyle; # Init globals
- if (pFontRecord[1]) # If we passed in a Font
- returnVal:= call (global gSetFont, pFontRecord[1],pObjectNumber); # Set the Font
- if not(pFontRecord[1]) or ((pFontRecord[1]) and (returnVal)) # don't want to continue if font selection failed.
- begin
- if (pFontRecord[2]) # If we passed in a Size
- returnVal := call (global gSetSize, pFontRecord[2],pObjectNumber); # Set the Size
-
- if (pResetPlainFlag) and (gPlainStyle)
- returnVal := call (global gSetStyle, gPlainStyle,pObjectNumber); # Reset to plain
-
- styleRecord := pFontRecord[3]; # Define the StyleRecord
- if(styleRecord)
- begin
- for each currentStyle in styleRecord # For all the Styles
- returnVal := call (global gSetStyle, currentStyle,pObjectNumber); # Set the Style
- end;
- end;
- if(returnVal)
- returnVal := pFontRecord;
- return(returnVal);
- end; # SetFontParams()
-
- #########################################################################
- # ReportSelectedMenuItems(pMenuList, pObjectNumber)
- #========================================================================
- # Author: KTA
- # Description: Collects all the menu items with a markChar ('') from the
- # defined menus defined in pMenuList. Then types each marked item
- # and calls NextLine() to move to the next text entry line.
- # Parameters: pMenuList - List of lists/strings
- # List of menus containing marked menuitems.
- # pObjectNumber - Integer used to track all elements that make up
- # an Font record - TCS related.
- # Returns: nada
- # Examples: ReportSelectedMenuItems({{'Format','Font'},{'Format','Styles'});
- # Assumptions:
- #========================================================================
- # History:
- # KTA 7/8/93 Check to see if duplicate items in pMenuList
- # KTA 8/24/93 TCS stack parity check
- # KTA 9/21/93 Removed gHandleTextEntry
- #########################################################################
- TASK ReportSelectedMenuItems(pMenuList, pObjectNumber)
- begin
- if global gReportSelectedMenuItems
- call (gReportSelectedMenuItems);
- else # if no custom Task for reporting selected
- begin
- failStr := '';
- markChar := ''; # MARK CHAR
- selectedItems := ""; # Init selectedItems
-
- ##Check to see if duplicate items in pMenuList
- tempMenuList := {};
- for each menuRec in pMenuList
- begin
- if not(isMember(menuRec, tempMenuList))
- tempMenuList := Insert(menuRec, Card(tempMenuList)+1, tempMenuList);
- end;
- pMenuList := tempMenuList;
-
- for each menuRecord in pMenuList
- begin
- currentMenu := 0; # reinitialize the currentmenu
- if not(TypeOf(menuRecord) = 'list') # Single menu item
- currentMenu := menuRecord;
- else if not(menuRecord[2]) # Menu is not hierarchical
- currentMenu := menuRecord[1];
- else # Menu is hierarchical
- activeList := collect[menuItem c:markChar m:[menuitem t:menuRecord[1] m:[menu t:menuRecord[2]]]]!;
-
- if(currentMenu)
- activeList := collect[menuItem c:markChar m:[menu t:currentMenu]]!;
- for each style in activeList
- begin
- selectedMenuItem := style.t;
- selectedItems := "{selectedItems}-{selectedMenuItem}"; # Build the list of selected menu items
- end;
- end;
- TCSStart({ 4, global kTCSetFont },"Type SelectedItems String"); # Start TCS
-
- if(selectedItems)
- begin
- TypeStr(selectedItems); # Type the selected menu items
- TCSFlag := 1; # Pass the TCS
- end;
- else
- TCSFlag := 0; # Fail the TCS
-
- DialogReturn := DialogCheck("",1); # Check to see if a dialog appeared
- if (DialogReturn)
- begin
- TCSFlag := 0; # Fail the TCS
- failStr := DialogReturn; # Set failStr to the string DialogCheck() returns
- end;
- TCSEnd({ 4, global kTCSetFont }, TCSFlag, failStr,pObjectNumber);
- end; # if no custom Task for reporting selected
- call (global gNextLine); # Move to the next line
- end; # ReportSelectedMenuItems()
-